#!/bin/bash


hangshu=$(cat /etc/passwd | wc -l) &> /dev/null

for i in $(seq $hangshu); do
     name=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $1}')
     password=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $2}')
     uid=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $3}')
     gid=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $4}')
     miaoshu=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $5}')
     lujing=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $6}')
     zhuangtai=$(cat /etc/passwd | head -$i | tail -1 | awk -F: '{print $7}')
     
     mysql -uroot -pWWW.1.com -e " insert into ds.user(name,password,uid,gid,miaoshu,lujing,zhuangtai) values('$name', '$password', '$uid', '$gid', '$miaoshu', '$lujing', '$zhuangtai');" 2> /dev/null
done
